﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;

namespace RestServices.Response.Calendar
{
    [DataContract]
    public class Event
    {
        [DataMember(Name = "id")]
        public string Id { get; set; }

        [DataMember(Name = "name")]
        public string Name { get; set; }

        [DataMember(Name = "description")]
        public string Description { get; set; }

        [DataMember(Name = "from")]
        public From From { get; set; }

        [DataMember(Name = "start_time")]
        public string StartTimeFormatted { get; set; }

        [DataMember(Name = "end_time")]
        public string EndTimeFormatted { get; set; }

        [DataMember(Name = "location")]
        public string Location { get; set; }

        [DataMember(Name = "is_all_day_event")]
        public string IsAllDayEvent { get; set; }

        [DataMember(Name = "is_recurrent")]
        public string IsRecurrent { get; set; }

        [DataMember(Name = "recurrence")]
        public string Recurrence { get; set; }

        [DataMember(Name = "reminder_time")]
        public string ReminderTime { get; set; }

        [DataMember(Name = "availability")]
        public string Availability { get; set; }

        [DataMember(Name = "visibility")]
        public string Visibility { get; set; }

        [DataMember(Name = "created_time")]
        public string CreatedTimeFormatted { get; set; }

        [DataMember(Name = "updated_time")]
        public string UpdatedTimeFormatted { get; set; }

        [IgnoreDataMember]
        public DateTime CreatedTime
        {
            get { return DateTime.ParseExact(CreatedTimeFormatted, "o", CultureInfo.InvariantCulture); }
            set { CreatedTimeFormatted = value.ToString("o"); }
        }

        [IgnoreDataMember]
        public DateTime UpdatedTime
        {
            get { return DateTime.ParseExact(UpdatedTimeFormatted, "o", CultureInfo.InvariantCulture); }
            set { UpdatedTimeFormatted = value.ToString("o"); }
        }

        [IgnoreDataMember]
        public DateTime StartTime
        {
            get { return DateTime.ParseExact(StartTimeFormatted, "o", CultureInfo.InvariantCulture); }
            set { StartTimeFormatted = value.ToString("o"); }
        }

        [IgnoreDataMember]
        public DateTime EndTime
        {
            get { return DateTime.ParseExact(EndTimeFormatted, "o", CultureInfo.InvariantCulture); }
            set { EndTimeFormatted = value.ToString("o"); }
        }
    }
}
